package com.inspur_video.inspur_video.controller;

import com.inspur_video.inspur_video.bean.Response;
import com.inspur_video.inspur_video.service.VipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * Created with IntelliJ IDEA.
 *
 * @author 小浩
 * @date 2018-07-25 17:25
 * @package com.inspur_video.inspur_video.controller
 * @description 会员控制器
 */
@RestController
@RequestMapping("/vip")
public class VipController {
    @Autowired
    HttpSession httpSession;
    @Autowired
    VipService vipService;
    @RequestMapping("/set")
    public Response setVip(String endTime){
        int id=Integer.parseInt(httpSession.getAttribute("user").toString());
        return vipService.setVip(id,endTime)? new Response(200,""):new
                Response(500,"");
    }

    @RequestMapping("/is")
    public Response isVip(){
        int id=Integer.parseInt(httpSession.getAttribute("user").toString());
        return vipService.isVip(id)?new Response(200,"是"):
                new Response(500,"否");
    }
}

